<%--
    Document   : tuychon
    Created on : Dec 8, 2011, 8:07:32 PM
    Author     : VIC
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.util.Vector,Beans.*,Models.*"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body onload="window.scrollTo(0, 1);">
        <%
         int langid = (Integer) session.getAttribute("langid");
            String mama = (String) request.getParameter("mama");
            String madvt = (String) request.getParameter("madvt");
            String ban = (String) request.getParameter("ban");
            String showphieu = (String) request.getParameter("showphieu");
            String dsts = "'option','notes','save','cancel','rqsent','selecttb','accep' "; // chuỗi chứa các mã tham số của trang này.
            ThamSoHT[] mdsts = ThamSoHT_Model.DSThamSo(dsts, langid); // mảng chứa các tham số của trang này.
            String accep = mdsts[0].getTenTS();
            String cancel = mdsts[1].getTenTS();
            String notes = mdsts[2].getTenTS();
            String option = mdsts[3].getTenTS();
            String rqsent = mdsts[4].getTenTS();
            String save = mdsts[5].getTenTS();
            String selecttb = mdsts[6].getTenTS();
        %>
        <div class="tabtitle"><%=notes %></div>
        <form name="phieugoi">
        <%
           
            String note = "";
            String tc="";
            if (session.getAttribute(ban) != null)
                {
                    Vector cart = (Vector) session.getAttribute(ban);
                    for(int k =0; k <cart.size();k++)
                    {
                        String[] monan = (String[]) cart.get(k);

                        if(monan[0].equals(mama) && monan[2].equals(madvt))
                        {            
                            String ghichu[] = monan[6].split("&&");
                            if (!ghichu[0].equals(""))
                            {
                                tc = ghichu[0];
                                note = ghichu[1].trim();
                            } else {
                                note = ghichu[1].trim();
                            }
                        }
                    }
                }
            String tuychon[] = tc.split(",");
            int tcsize = tuychon.length ;
            Vector vtc = TuyChon_Model.LoadTuyChon(langid, mama);
             int n = vtc.size();
             if(n >0)
             {
                 %>
                 
                 <div>
                     <p><%=option %> :</p>
                     <table>
                         
                <%
                if( tcsize >0) {
                for (int i = 0; i < n; i++) {
                    TuyChon tam = (TuyChon) vtc.get(i);
                         int check =0;
                         for(int f=0; f < tcsize;f++)
                         {
                             if(!tuychon[f].equals(""))
                             {
                                 if(Integer.parseInt(tuychon[f]) == tam.getMaTC())
                                 { check = 1; break; }
                             }
                             
                         }
                         if(check == 1)
                         {
                %>
                        <tr>
                            <td><%= tam.getTenTC() %></td>
                            <td><input checked="true"   type="checkbox" name="dstc" value="<%= tam.getMaTC() %>"/></td>
                        </tr>
                        <%} else {%>
                       <tr>
                            <td><%= tam.getTenTC() %></td>
                            <td><input   type="checkbox" name="dstc" value="<%= tam.getMaTC() %>"/></td>
                        </tr>
                        <% }}} else {
                         for (int i = 0; i < n; i++) {
                        TuyChon tam = (TuyChon) vtc.get(i);
                        %>
                        <tr>
                            <td><%= tam.getTenTC() %></td>
                            <td><input   type="checkbox" name="dstc" value="<%= tam.getMaTC() %>"/></td>
                        </tr>
                        <% } }%>
                        </table>
                        </div>
                          <div>
                              <p><%=notes %> :</p>
                              <textarea name="ghichu" cols="22" rows="5"><%= note %></textarea>
                          </div>

                          <% } else {%>
                          <p><%=notes %> :</p>
                          <textarea name="ghichu" cols="22" rows="6"><%= note %></textarea>
                          <% } %>
                          <input type="button" onclick="LuuTuyChon('<%=selecttb %>','<%=accep %>','<%=rqsent %>','<%=mama %>','<%=madvt %>',<%=showphieu %>);" value="<%=save %>"/>
                          <input onclick="DongTuyChon('<%=selecttb %>','<%=accep %>',<%=showphieu %>)" type="button" value="<%=cancel %>"/>
                          </form>
    </body>
</html>
